package cn.liyunqi.prplug;

import cn.liyunqi.prplug.controller.PrPlugController;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

import java.net.URL;
import java.util.HashMap;

/**
 * @Auther: li.yunqi
 * @Date: 2019/10/12 15:55
 * @Description: TODO
 */
//@SpringBootApplication
public class PrPlugApplication extends Application {

    public void start(Stage primaryStage) throws Exception {

        URL url = Thread.currentThread().getContextClassLoader().getResource("fxml/PrPlugMain.fxml");
        FXMLLoader fxmlLoader = new FXMLLoader(url);
        Parent root = fxmlLoader.load();
        primaryStage.setResizable(true);
        primaryStage.setTitle("PrPlug");
        //primaryStage.setMaximized(true);
        Scene scene = new Scene(root,1243,849);
        primaryStage.setScene(scene);
        //scene.getStylesheets().add(FindImgMainController.class.getResource("css/style.css").toExternalForm());

        primaryStage.show();
        primaryStage.getIcons().add(new Image("icons/icon.png"));

        PrPlugController controller = fxmlLoader.getController();
        controller.setPrimaryStage(primaryStage);

        primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent event) {

                controller.closeHandler();

            }
        });
    }

    public static void main(String[] args){
        launch(args);
    }
}